package chapter12;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2018-03-23 下午2:40
 */
public class MultiTreadServer {
    public static void main(String[] args) {
        System.out.println("waiting for connecting...");
        boolean flag = true;
        try (ServerSocket server = new ServerSocket(6001)) {
            while (flag) {
                Socket socket = server.accept();
                new Thread(new EchoThread(socket)).start();
            }
            server.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
